package com.huike.web.controller.report;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.huike.clues.service.impl.GetTodayInfoservice;
import com.huike.common.core.domain.entity.SysUser;
import com.huike.common.core.domain.model.LoginUser;
import com.huike.common.utils.ServletUtils;
import com.huike.framework.web.service.TokenService;
import com.huike.report.domain.vo.Tagger;
import org.jetbrains.annotations.TestOnly;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;
    @Autowired
    public GetTodayInfoservice getTodayInfoservice;
    @Autowired
    public TokenService tokenService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){

        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        SysUser user = loginUser.getUser();
        Map<String, String> map = getTodayInfoservice.get(user);
        return AjaxResult.success(map);
        //reportService.

    }
    @GetMapping("/getTodoInfo")
    public AjaxResult getInVo(@RequestParam("beginCreateTime") String beginCreateTime,
                              @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getVo(beginCreateTime,endCreateTime));
    }
    @GetMapping("/businessChangeStatistics")
    public AjaxResult gettagger(String beginCreateTime, String endCreateTime){
        List<Tagger> list = reportService.getcuntegger(beginCreateTime,endCreateTime);
        return new AjaxResult(200, "操作成功", list);

    }
    @GetMapping("/salesStatistic")
    public AjaxResult gettagger2(String beginCreateTime, String endCreateTime) {
        List<Tagger> list = reportService.getcuntegger2(beginCreateTime, endCreateTime);
        return new AjaxResult(200, "操作成功", list);
    }

}
